# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=x264
pkgver=20191119
pkgrel=1
pkgdesc="Free library for encoding H264/AVC video streams"
url="http://www.videolan.org/developers/x264.html"
arch="all"
license="GPL-2.0-or-later"
makedepends="libx11-dev bash nasm coreutils perl"
subpackages="$pkgname-dev $pkgname-libs"
source="https://download.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-$pkgver-2245-stable.tar.bz2"
builddir="$srcdir/$pkgname-snapshot-$pkgver-2245-stable"

build() {
	local asmopts=
	case "$CARCH" in
		# x86 assembly contains TEXTRELs
		x86)	    asmopts="--disable-asm";;

		# mips targets are soft-float
		mips*)	    asmopts="--disable-asm";;
	esac

	# note: not autotools
	CFLAGS="${CFLAGS/-Os/}" ./configure \
		--host=$CHOST \
		--prefix=/usr \
		--enable-shared \
		--enable-static \
		$asmopts \
		--enable-pic \
		--extra-cflags=-fno-aggressive-loop-optimizations
	make
}

check() {
	./x264 --version
}

package() {
	make DESTDIR="$pkgdir" \
		bindir=/usr/bin libdir=/usr/lib includedir=/usr/include \
		install
}

sha512sums="972a9a2a939a275b087c10af511f3d737fbfc3daff49cd175f28406da6ebafaa4696ee362d3b84dd8ae04275812189da6929f9d987c5aa8bb216c9324cf8f55e  x264-snapshot-20191119-2245-stable.tar.bz2"
